package service

import (
	"context"
	"douyin_mini/cmd/comment/dal/db"
	"douyin_mini/kitex_gen/comment"
)

type CommentActionService struct {
	ctx context.Context
}

func NewCommentActionService(ctx context.Context) *CommentActionService {
	return &CommentActionService{ctx: ctx}
}

// CommentAction 具体的service层业务逻辑
func (s *CommentActionService) CommentAction(req *comment.CommentActionRequest) error {
	if req.ActionType == 1 {
		commentReqModel := &db.Comment{
			VideoId: req.VideoId,
			UserId:  req.UserId,
			Content: *req.CommentText,
		}
		return db.CreateComment(s.ctx, []*db.Comment{commentReqModel})
	} else {
		return db.DeleteComment(s.ctx, *req.CommentId)
	}
}
